package git.jas0nch.final4it.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.servlet.config.annotation.*;

/**
 * projectName : final4it
 * className: MVCConfig
 * description: 静态资源路径访问的配置，restTemplate依赖的注入。
 *
 * @author : chengjiang@asiainfo.com
 * @date : 2022/05/06
 */

@Configuration
@EnableWebMvc
public class MVCConfig implements WebMvcConfigurer {

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        //开放static,templates,public 目录 但是请求时候需要加上对应的前缀,比如我访问static下的资源/static/xxxx/xx.js
        registry.addResourceHandler("/static/**","/templates/**","/public/**")
                .addResourceLocations("classpath:/static/","classpath:/templates/","classpath:/public/");

    }

    //
    /**
     * @description : 用java 的方式获取请求 并返回数据：
     * @param
     * @return : org.springframework.web.client.RestTemplate
     * @author : git.jas0nch
     * date : 2022/5/5
     **/
    @Bean
    public RestTemplate getRestTemplate(){
        return new RestTemplate();
    }
}
